package com.zc.zby.basicframedemo.viewholder;

import android.support.v7.widget.CardView;
import android.view.View;
import android.view.ViewGroup;

import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.zc.zby.basicframedemo.R;
import com.zc.zby.basicframedemo.model.ProgressModel;
import com.zc.zby.basicframedemo.utils.ToolUtil;
import com.zc.zby.basicframedemo.weight.RoundProgressBar;

public class Progress2ViewHolder extends BaseViewHolder<ProgressModel> {

    private RoundProgressBar mProgressBar;
    private CardView mCardView;

    public Progress2ViewHolder(View itemView) {
        super(itemView);
        mProgressBar = $(R.id.rpb);
        mCardView = $(R.id.cardview);
    }

    @Override
    public void setData(ProgressModel data) {
        super.setData(data);
        mProgressBar.setCurrentProgress(data.currentValue);
        mProgressBar.setMaxProgress(data.maxValue);
        mProgressBar.setProgressStartColor(data.startColor);
        mProgressBar.setProgressEndColor(data.endColor);
        ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) mCardView.getLayoutParams();
        layoutParams.setMargins(ToolUtil.dip2px(getContext(), 4), ToolUtil.dip2px(getContext(), 4), ToolUtil.dip2px(getContext(), 4), ToolUtil.dip2px(getContext(), 4));
        mCardView.setLayoutParams(layoutParams);
    }
}
